package com.zhangjianling.premp.entity.sys;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 部门管理
 * 
 * @author zhangjl
 *
 */

@Entity
@Table(name="sys_dept")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysDept implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid.hex")
	@Column(name = "deptid", nullable = false)
	private String deptId;

	@Column(name = "name")
	private String name;

	@Column(name="deptCode",length=50)
	private String deptCode;

	@ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	private SysDept parentDept;

	@OneToMany(targetEntity= SysDept.class,cascade = { CascadeType.ALL},fetch = FetchType.LAZY, mappedBy = "parentDept")
	@JsonIgnore
	private List<SysDept> childDept = new ArrayList<SysDept>();

	@Column(name = "createtime",updatable=false)
	private String createTime;

	@Column(name = "updatetime")
	private String updateTime;

	@Column(name = "createuser",updatable=false)
	private String createUser;

	@Column(name = "updateuser")
	private String updateUser;

	@Transient
	@Column(name="pid")
	private String pId;

	@Column(name = "remark")
	private String remark;

	
}
